// The MIT License (MIT)

// Copyright (c) 2016, 2017, 2019 by German A. Arias

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in 
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#include <stdlib.h>
#include <iup.h>
#include <iupkey.h>
#include <im.h>
#include <im_image.h>
#include <iupim.h>
#include <iup_config.h>
#include <iupcontrols.h>

// For eiffel-cd
#include <cd.h>
#include <wd.h>
#include <cdiup.h>

int iup_init(int argc, char *argv[]);
void iup_main_loop();
void iup_close();
int get_param_dialog (const char* title, void* user_data, const char* format, int param_count, int param_extra, void** param_data);
int param_action(Ihandle* dialog, int param_index, void* user_data);
void config_recent_init (Ihandle* ih, Ihandle* menu, int max_recent);
void connect_function (const char *name, int operation);
void connect_callback (Ihandle* ih, const char *name, const char *type, int operation);
int callback_idle_action(void);
int callback_idle_action(void);
void callback_help_cb(Ihandle *ih);
int callback_map_cb(Ihandle *ih);
int callback_unmap_cb(Ihandle *ih);
int callback_destroy_cb(Ihandle *ih);
int callback_ldestroy_cb(Ihandle *ih);
int callback_getfocus_cb(Ihandle *ih);
int callback_killfocus_cb(Ihandle *ih);
int callback_enterwindow_cb(Ihandle *ih);
int callback_leavewindow_cb(Ihandle *ih);
int callback_k_any(Ihandle *ih, int c);
int callback_action_Fn(Ihandle *object);
int callback_close_cb(Ihandle *ih);
int callback_copydata_cb(Ihandle *ih, char* cmdLine, int size);
int callback_dropfiles_cb(Ihandle *ih, char* filename, int num, int x, int y);
int callback_mdiactivate_cb(Ihandle *ih);
int callback_move_cb(Ihandle *ih, int x, int y);
int callback_resize_cb(Ihandle *ih, int width, int height);
int callback_show_cb(Ihandle *ih, int state);
int callback_trayclick_cb(Ihandle *ih, int but, int pressed, int dclick);
int callback_file_cb(Ihandle *ih, char* file_name, char* status);
int callback_colorupdate_cb (Ihandle *ih);
int callback_cancel_cb (Ihandle* ih);
int callback_tabchange_cb(Ihandle *ih, Ihandle* new_tab, Ihandle* old_tab);
int callback_tabchangepos_cb(Ihandle *ih, int new_pos, int old_pos);
int callback_tabclose_cb(Ihandle *ih, int pos);
int callback_rightclick_cb(Ihandle *ih, int pos);
int callback_detached_cb(Ihandle *ih, Ihandle *new_parent, int x, int y);
int callback_restored_cb(Ihandle *ih, Ihandle *old_parent, int x, int y);
int callback_openclose_cb(Ihandle *ih, int state);
int callback_extrabutton_cb(Ihandle *ih, Ihandle *new_parent, int button, int pressed);
int callback_valuechanged_cb(Ihandle *ih);
int callback_button_cb(Ihandle *ih, int button, int pressed, int x, int y, char* status);
int callback_action_Fnff(Ihandle *ih, float posx, float posy);
int callback_focus_cb(Ihandle *ih, int focus);
int callback_motion_cb(Ihandle *ih, int x, int y, char *status);
int callback_keypress_cb(Ihandle *ih, int c, int press);
int callback_scroll_cb(Ihandle *ih, int op, float posx, float posy);
int callback_wheel_cb(Ihandle *ih, float delta, int x, int y, char *status);
int callback_click_cb(Ihandle *ih, char *url);
int callback_action_Fnsii(Ihandle *ih, char *text, int item, int state);
int callback_caret_cb(Ihandle *ih, int lin, int col, int pos);
int callback_dblclick_cb(Ihandle *ih, int item, char *text);
int callback_dragdrop_cb(Ihandle *ih, int drag_id, int drop_id, int isshift, int iscontrol);
int callback_dropdown_cb(Ihandle *ih, int state);
int callback_edit_cb(Ihandle *ih, int c, char *new_value);
int callback_multiselect_cb(Ihandle *ih, char *value);
int callback_spin_cb(Ihandle *ih, int inc);
int callback_action_Fnis(Ihandle *ih, int c, char *new_value);
int callback_action_Fni(Ihandle* ih, int state);
int callback_selection_cb (Ihandle *ih, int id, int status);
int callback_multiselection_cb (Ihandle *ih, int* ids, int n);
int callback_multiunselection_cb (Ihandle *ih, int* ids, int n);
int callback_branchopen_cb (Ihandle *ih, int id);
int callback_branchclose_cb (Ihandle *ih, int id);
int callback_executeleaf_cb (Ihandle *ih, int id);
int callback_showrename_cb (Ihandle *ih, int id);
int callback_rename_cb (Ihandle *ih, int id, char *title);
int callback_noderemoved_cb (Ihandle *ih, void* userdata);
int callback_togglevalue_cb_Fnii (Ihandle *ih, int id, int state);
int callback_highlight_cb (Ihandle *ih);
int callback_open_cb (Ihandle *ih);
int callback_menuclose_cb (Ihandle *ih);
int callback_dragbegin_cb (Ihandle* ih, int x, int y);
int callback_dragdatasize_cb (Ihandle* ih, char* type);
int callback_dragdata_cb (Ihandle* ih, char* type, void* data, int size);
int callback_dragend_cb (Ihandle* ih, int action);
int callback_dropdata_cb (Ihandle* ih, char* type, void* data, int size, int x, int y);
int callback_dropmotion_cb (Ihandle *ih, int x, int y, char *status);
int callback_recent_cb (Ihandle *ih);
int callback_flat_action_Fn(Ihandle *object);
int callback_flat_button_cb(Ihandle *ih, int button, int pressed, int x, int y, char* status);
int callback_flat_focus_cb(Ihandle *ih, int focus);
int callback_flat_enterwindow_cb(Ihandle *ih);
int callback_flat_leavewindow_cb(Ihandle *ih);
int callback_draw_cb(Ihandle* ih, int line, int column, int xmin, int xmax, int ymin, int ymax, cdCanvas* canvas);
int callback_height_cb(Ihandle* ih, int line);
int callback_hspan_cb(Ihandle* ih, int line, int column);
int callback_mouseclick_cb(Ihandle* ih, int button, int pressed, int line, int column, int x, int y, char* status);
int callback_mousemotion_cb(Ihandle *ih, int line, int column, int x, int y, char *r);
int callback_ncols_cb(Ihandle* ih);
int callback_nlines_cb(Ihandle* ih);
int callback_scrolling_cb(Ihandle* ih, int line, int column);
int callback_vspan_cb(Ihandle* ih, int line, int column);
int callback_width_cb(Ihandle* ih, int column);
char* callback_cell_cb(Ihandle* ih, int cell);
int callback_extended_cb(Ihandle* ih, int cell);
int callback_select_cb(Ihandle* ih, int cell, int type);
int callback_switch_cb(Ihandle* ih, int prim_cell, int sec_cell);
int callback_action_Fniiiis(Ihandle *ih, int key, int lin, int col, int edition, char* value);
int callback_click_cb_Fniis (Ihandle *ih, int lin, int col, char *status);
int callback_colresize_cb (Ihandle *ih, int col);
int callback_release_cb (Ihandle *ih, int lin, int col, char *status);
int callback_resizematrix_cb (Ihandle *ih, int width, int height);
int callback_mousemove_cb (Ihandle *ih, int lin, int col);
int callback_enteritem_cb (Ihandle *ih, int lin, int col);
int callback_leaveitem_cb (Ihandle *ih, int lin, int col);
int callback_scrolltop_cb (Ihandle *ih, int lin, int col);
int callback_bgcolor_cb (Ihandle *ih, int lin, int col, int *red, int *green, int *blue);
int callback_fgcolor_cb (Ihandle *ih, int lin, int col, int *red, int *green, int *blue);
char* callback_font_cb (Ihandle* ih, int lin, int col);
char* callback_type_cb (Ihandle* ih, int lin, int col);
int callback_dropcheck_cb (Ihandle *ih, int lin, int col);
char* callback_translatevalue_cb (Ihandle* ih, int lin, int col, char* value);
int callback_togglevalue_cb_Fniii (Ihandle *ih, int lin, int col, int status);
int callback_drop_cb (Ihandle *ih, Ihandle *drop, int lin, int col);
int callback_menudrop_cb (Ihandle *ih, Ihandle *drop, int lin, int col);
int callback_dropselect_cb (Ihandle *ih, int lin, int col, Ihandle *drop, char *t, int i, int v);
int callback_edition_cb (Ihandle *ih, int lin, int col, int mode, int update);
char* callback_value_cb (Ihandle* ih, int lin, int col);
int callback_value_edit_cb (Ihandle *ih, int lin, int col, char* newval);
int callback_mark_cb (Ihandle* ih, int lin, int col);
int callback_markedit_cb (Ihandle *ih, int lin, int col, int marked);
int callback_flat_motion_cb(Ihandle *ih, int x, int y, char *status);
int callback_flat_dropshow_cb(Ihandle *ih, int state);
int callback_button_press_cb(Ihandle *ih, double angle);
int callback_button_release_cb(Ihandle *ih, double angle);
int callback_mousemove_cb_Fnd (Ihandle *ih, double angle);
int callback_change_cb (Ihandle *ih, unsigned char r, unsigned char g, unsigned char b);
int callback_drag_cb (Ihandle *ih, unsigned char r, unsigned char g, unsigned char b);
